package XMLReader;

import java.util.ArrayList;

/**
 *
 * @author moti
 */
public class XMLEntry
{
    private XMLEntry parent;
    private String name;
    private String content;
    private ArrayList<XMLEntry> children;
    
    XMLEntry (String name) {
		this.name = name;
		this.parent = null;
		this.content = "";
		children = new ArrayList<XMLEntry>();
	}

	public String name () 
        {
		return this.name;
	}
	
	public XMLEntry parent() 
        {
		return this.parent;
	}
	
	public void parent(XMLEntry parent) 
        {
		this.parent = parent;
	}
	
	public String content() 
        {
		return this.content;
	}
	
	public void content(String content) 
        {
		this.content = content;
	}
	
	public Boolean hasChildren() 
        {
		return !children.isEmpty();
	}
	
	public ArrayList<XMLEntry> children() 
        {		
		return children;
	}

	public void add (XMLEntry entry) 
        {
		children.add(entry);
	}
	
	public XMLEntry find(String name) 
        {
		XMLEntry entry = null;
		for (int i = 0; i < children.size(); i++) 
                {
			entry = children.get(i);
			if (name.equals(entry.name())) 
                            break;
		}
		return entry;
	}


}

